@echo off
setlocal enabledelayedexpansion
rem 定义一个以分号作为分隔的字符串
set allGitAddresses=git@gitee.com:argus-plat/argus-backend-compose.git;git@gitee.com:argus-plat/argus-backend.git;git@gitee.com:argus-plat/argus-common.git;git@gitee.com:argus-plat/argus-job.git
rem 设定分支
set branch=master
rem 剩余字符副本
set remain=%allGitAddresses%
set projects=
:loop
for /f "tokens=1* delims=;" %%a in ("%remain%") do (
  
  set gitAddr=%%a
  rem 将截取剩下的部分赋给变量remain
  set remain=%%b

  rem clone
  echo !gitAddr!
  git clone !gitAddr!
  
  rem 切换分支
  rem 获取子工程名称， 取25（git@gitee.com:argus-plat/ 后）到 .git前
  set projectName=!gitAddr:~25,-4!
  echo !projectName!
  cd !projectName!
  git checkout !branch!
  cd ../
  set projects=!projects! !projectName!
  
)
::如果还有剩余,则继续分割
if defined remain goto :loop

echo Projects!projects! have been check out to branch !branch!.
pause